package team.zero.lemon.common.listener;

import team.zero.lemon.common.config.Global;
import org.springframework.web.context.WebApplicationContext;

import javax.servlet.ServletContext;

/**
 * Created by bolin on 2016/5/6.
 */
public class WebContextListener  extends org.springframework.web.context.ContextLoaderListener {

    @Override
    public WebApplicationContext initWebApplicationContext(ServletContext servletContext) {
        if (!printKeyLoadMessage()){
            return null;
        }
        return super.initWebApplicationContext(servletContext);
    }
    public static boolean printKeyLoadMessage(){
        StringBuilder sb = new StringBuilder();
        sb.append("\r\n======================================================================\r\n");
        sb.append("\r\n    欢迎使用 "+ Global.getConfig("application.name")+"  - Powered By zero\r\n");
        sb.append("\r\n======================================================================\r\n");
        System.out.println(sb.toString());
        return true;
    }
}
